import { FC } from "react";
import { RouteProps } from "react-router";

import PrivateRoute from "./provateRoute";

export type WrapperrRouteProps = RouteProps & { auth?: boolean };

/**
 *根据组件上的 auth 参数判断组件是否需要验证登录才能加载
 */
const WapperRoutComponent: FC<WrapperrRouteProps> = ({ auth, children }) => {
  if (auth) {
    return <PrivateRoute>{children}</PrivateRoute>;
  }
  return <>{children}</>;
};

export default WapperRoutComponent;
